home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-09 | 4.2 KB | 123 lines | [TEXT/CWIE] |
- // =================================================================================
- // CDragTask.h ©1995 J. Rodden, DD/MF & Associates. All rights reserved
- // =================================================================================
- // You do not need to inherit this class.
- //
- // LDragTask gives us general drag functionality and behaviour. CDragTask exists so
- // that we can add behaviour specific to dragging our items without having to inherit
- // from LDragTask anymore.
- //
- // CDragTask actually acts as a stub object, it passes the work onto the object being
- // dragged so that all drag manager code can be isolated in the object being dragged
- // or its owner and you don't ever have to deal with an LDragTask again.
- //
- // By using CDragTask and overriding AddFlavors and MakeDragRegion in the object
- // being dragged, you can (a) include as many flavors of an item as you want, (b)
- // define your own outline to replace the generic rectangle that LDragTask provides,
- // (c) arrange to send drag data on demand by calling InstallDragSendData when
- // adding flavors (and installing null data in the drag) and overriding DoSendDragData
- // for the object being dragged, and (d) override the drag manager's default behaviors
- // for DragInput and DragDrawing by calling InstallDragInput or InstallDragDrawing
- // and overriding DoDragInput or DoDragDrawing respectively.
- // =================================================================================
-
- #include "CDragTask.h"
- #include "CDragItem.h"
-
- // =================================================================================
- // • CDragTask
- // =================================================================================
-
- CDragTask::CDragTask(
- const EventRecord &inEventRecord,
- CDragItem* inDragItem)
-
- : LDragTask(inEventRecord),
- dragItem(inDragItem)
- {
- }
-
-
- // =================================================================================
- // • CDragTask
- // =================================================================================
-
- CDragTask::CDragTask (
- const EventRecord& inEventRecord,
- const Rect* inItemRect,
- ItemReference inItemRef,
- CDragItem* inDragItem)
-
- : LDragTask(inEventRecord),
- dragItem(inDragItem)
- {
- if ( inItemRect != nil ) { // optionally provide default drag outline
- Rect globalRect = *inItemRect;
- ::LocalToGlobal(&topLeft(globalRect));
- ::LocalToGlobal(&botRight(globalRect));
- AddRectDragItem(inItemRef, globalRect);
- }
- }
-
-
- // =================================================================================
- // • AddFlavors
- // =================================================================================
- // Let the object being dragged add the drag flavors.
-
- void
- CDragTask::AddFlavors (DragReference inDragRef)
- {
- if (dragItem) dragItem->AddFlavors(inDragRef);
- }
-
-
- // =================================================================================
- // • MakeDragRegion
- // =================================================================================
- // Let the object being dragged make the drag region.
-
- void
- CDragTask::MakeDragRegion( DragReference inDragRef, RgnHandle inDragRegion)
- {
- if (dragItem) dragItem->MakeDragRegion(inDragRef,inDragRegion);
- }
-
-
- // =================================================================================
- // • InstallDragSendData
- // =================================================================================
- // Let the object being dragged override default DragSendData behavior.
-
- void
- CDragTask::InstallDragSendData()
- {
- if (dragItem) dragItem->InstallDragSendData(mDragRef);
- }
-
-
- // =================================================================================
- // • InstallDragInput
- // =================================================================================
- // Let the object being dragged override default DragInput behavior.
-
- void
- CDragTask::InstallDragInput()
- {
- if (dragItem) dragItem->InstallDragInput(mDragRef);
- }
-
-
- // =================================================================================
- // • InstallDragDrawing
- // =================================================================================
- // Let the object being dragged override default DragDrawing behavior.
-
- void
- CDragTask::InstallDragDrawing()
- {
- if (dragItem) dragItem->InstallDragDrawing(mDragRef);
- }
-
-
-